```html
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>网络协议解析：ARP与RARP</title>
    <link rel="stylesheet" href="https://cdn.staticfile.org/font-awesome/6.4.0/css/all.min.css">
    <link rel="stylesheet" href="https://cdn.staticfile.org/tailwindcss/2.2.19/tailwind.min.css">
    <link href="https://fonts.googleapis.com/css2?family=Noto+Serif+SC:wght@400;500;600;700&family=Noto+Sans+SC:wght@300;400;500;700&display=swap" rel="stylesheet">
    <script src="https://cdn.jsdelivr.net/npm/mermaid@latest/dist/mermaid.min.js"></script>
    <style>
        body {
            font-family: 'Noto Sans SC', Tahoma, Arial, Roboto, "Droid Sans", "Helvetica Neue", "Droid Sans Fallback", "Heiti SC", "Hiragino Sans GB", Simsun, sans-serif;
            background-color: #f8fafc;
            color: #1e293b;
        }
        h1, h2, h3, h4 {
            font-family: 'Noto Serif SC', serif;
        }
        .hero-gradient {
            background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
        }
        .protocol-card {
            transition: all 0.3s ease;
            box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
        }
        .protocol-card:hover {
            transform: translateY(-5px);
            box-shadow: 0 10px 15px rgba(0, 0, 0, 0.1);
        }
        .highlight-text {
            background: linear-gradient(90deg, #e0e7ff, transparent);
            padding: 0.2rem 0.5rem;
            border-left: 4px solid #4f46e5;
        }
        .step-icon {
            width: 40px;
            height: 40px;
            background-color: #4f46e5;
            color: white;
            border-radius: 50%;
            display: flex;
            align-items: center;
            justify-content: center;
            margin-right: 1rem;
            flex-shrink: 0;
        }
        .footer-link:hover {
            color: #a5b4fc;
        }
        .mermaid {
            background-color: white;
            border-radius: 0.5rem;
            padding: 1.5rem;
            box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
        }
    </style>
</head>
<body>
    <!-- Hero Section -->
    <section class="hero-gradient text-white py-20 px-4 md:py-32">
        <div class="container mx-auto max-w-5xl">
            <div class="flex flex-col md:flex-row items-center">
                <div class="md:w-1/2 mb-10 md:mb-0">
                    <h1 class="text-4xl md:text-5xl font-bold leading-tight mb-4">ARP与RARP协议深度解析</h1>
                    <p class="text-xl opacity-90 mb-8">探索网络地址解析的底层机制与现代应用</p>
                    <div class="flex flex-wrap gap-4">
                        <a href="#arp-section" class="bg-white text-indigo-600 px-6 py-3 rounded-md font-medium hover:bg-indigo-50 transition duration-300">
                            <i class="fas fa-network-wired mr-2"></i>了解ARP
                        </a>
                        <a href="#rarp-section" class="bg-indigo-700 text-white px-6 py-3 rounded-md font-medium hover:bg-indigo-800 transition duration-300">
                            <i class="fas fa-sync-alt mr-2"></i>了解RARP
                        </a>
                    </div>
                </div>
                <div class="md:w-1/2 flex justify-center">
                    <div class="bg-white/10 backdrop-blur-sm rounded-xl p-6 border border-white/20 w-full max-w-md">
                        <div class="mermaid">
                            graph LR
                                A[IP地址] -- ARP --> B[MAC地址]
                                B -- RARP --> A
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </section>

    <!-- Main Content -->
    <main class="container mx-auto max-w-5xl py-12 px-4">
        <!-- Introduction -->
        <section class="mb-20">
            <div class="bg-white rounded-xl shadow-md p-8">
                <h2 class="text-2xl font-bold mb-6 text-indigo-700">地址解析协议概述</h2>
                <p class="text-lg leading-relaxed mb-6">
                    ARP（Address Resolution Protocol）和 RARP（Reverse Address Resolution Protocol）是网络通信中两个基础但至关重要的协议，它们分别解决了从 <span class="font-medium text-indigo-600">IP地址到MAC地址</span> 和从 <span class="font-medium text-indigo-600">MAC地址到IP地址</span> 的映射问题。
                </p>
                <div class="grid grid-cols-1 md:grid-cols-2 gap-6 mt-8">
                    <div class="protocol-card bg-white border border-gray-100 rounded-lg p-6">
                        <div class="flex items-center mb-4">
                            <div class="bg-indigo-100 w-12 h-12 rounded-full flex items-center justify-center mr-4">
                                <i class="fas fa-project-diagram text-indigo-600 text-xl"></i>
                            </div>
                            <h3 class="text-xl font-bold">ARP协议</h3>
                        </div>
                        <p class="text-gray-600">将IP地址解析为MAC地址，是局域网通信的基础协议，在现代网络中仍广泛应用。</p>
                    </div>
                    <div class="protocol-card bg-white border border-gray-100 rounded-lg p-6">
                        <div class="flex items-center mb-4">
                            <div class="bg-purple-100 w-12 h-12 rounded-full flex items-center justify-center mr-4">
                                <i class="fas fa-history text-purple-600 text-xl"></i>
                            </div>
                            <h3 class="text-xl font-bold">RARP协议</h3>
                        </div>
                        <p class="text-gray-600">将MAC地址解析为IP地址，主要用于设备启动时获取IP地址，现多被DHCP取代。</p>
                    </div>
                </div>
            </div>
        </section>

        <!-- ARP Section -->
        <section id="arp-section" class="mb-20">
            <div class="bg-white rounded-xl shadow-md p-8">
                <div class="flex items-center mb-8">
                    <div class="bg-indigo-100 w-14 h-14 rounded-xl flex items-center justify-center mr-6">
                        <i class="fas fa-network-wired text-indigo-600 text-2xl"></i>
                    </div>
                    <h2 class="text-3xl font-bold text-indigo-700">ARP（地址解析协议）</h2>
                </div>
                
                <p class="text-lg leading-relaxed mb-8">
                    ARP（Address Resolution Protocol）是一种网络协议，用于将 IP 地址解析为 MAC 地址（物理地址）。在局域网中，当一台设备知道目标设备的 IP 地址时，它需要通过 ARP 协议找到对应的 MAC 地址，从而可以进行数据包的正确传输。
                </p>
                
                <h3 class="text-2xl font-semibold mb-6 text-indigo-600 border-b border-indigo-100 pb-2">工作原理</h3>
                
                <div class="space-y-6 mb-10">
                    <div class="flex items-start">
                        <div class="step-icon">
                            <i class="fas fa-bullhorn"></i>
                        </div>
                        <div>
                            <h4 class="font-bold text-lg mb-2">ARP 请求</h4>
                            <p class="text-gray-700">设备 A 知道设备 B 的 IP 地址，但不知道设备 B 的 MAC 地址。设备 A 发送一个 ARP 请求广播到网络中，请求包含了目标 IP 地址。</p>
                        </div>
                    </div>
                    
                    <div class="flex items-start">
                        <div class="step-icon">
                            <i class="fas fa-reply"></i>
                        </div>
                        <div>
                            <h4 class="font-bold text-lg mb-2">ARP 响应</h4>
                            <p class="text-gray-700">设备 B 收到 ARP 请求后，回复 ARP 响应，其中包含了设备 B 的 MAC 地址。</p>
                        </div>
                    </div>
                    
                    <div class="flex items-start">
                        <div class="step-icon">
                            <i class="fas fa-database"></i>
                        </div>
                        <div>
                            <h4 class="font-bold text-lg mb-2">缓存和通信</h4>
                            <p class="text-gray-700">设备 A 收到 ARP 响应后，将设备 B 的 IP 地址和 MAC 地址映射存储在 ARP 缓存中，然后使用该 MAC 地址将数据包发送给设备 B。</p>
                        </div>
                    </div>
                </div>
                
                <h3 class="text-2xl font-semibold mb-4 text-indigo-600 border-b border-indigo-100 pb-2">主要用途</h3>
                <p class="text-lg leading-relaxed mb-6">
                    将 IP 地址映射到物理网络地址（MAC 地址），以便在局域网中正确路由数据包。
                </p>
                
                <div class="mermaid mt-10">
                    sequenceDiagram
                        participant A as 设备A
                        participant B as 设备B
                        A->>网络: ARP请求: 谁的IP是192.168.1.2?
                        B->>A: ARP响应: 我是192.168.1.2,MAC是00:1A:2B:3C:4D:5E
                        A->>B: 数据包(使用MAC地址)
                </div>
            </div>
        </section>

        <!-- RARP Section -->
        <section id="rarp-section" class="mb-20">
            <div class="bg-white rounded-xl shadow-md p-8">
                <div class="flex items-center mb-8">
                    <div class="bg-purple-100 w-14 h-14 rounded-xl flex items-center justify-center mr-6">
                        <i class="fas fa-sync-alt text-purple-600 text-2xl"></i>
                    </div>
                    <h2 class="text-3xl font-bold text-purple-700">RARP（反向地址解析协议）</h2>
                </div>
                
                <p class="text-lg leading-relaxed mb-8">
                    RARP（Reverse Address Resolution Protocol）是一种网络协议，用于将 MAC 地址解析为 IP 地址。它通常用于设备在启动时，特别是那些没有存储持久 IP 地址的设备，如网络启动设备（例如，无盘工作站）。
                </p>
                
                <h3 class="text-2xl font-semibold mb-6 text-purple-600 border-b border-purple-100 pb-2">工作原理</h3>
                
                <div class="space-y-6 mb-10">
                    <div class="flex items-start">
                        <div class="step-icon" style="background-color: #8b5cf6;">
                            <i class="fas fa-broadcast-tower"></i>
                        </div>
                        <div>
                            <h4 class="font-bold text-lg mb-2">RARP 请求</h4>
                            <p class="text-gray-700">设备发送 RARP 请求广播，包含设备的 MAC 地址。</p>
                        </div>
                    </div>
                    
                    <div class="flex items-start">
                        <div class="step-icon" style="background-color: #8b5cf6;">
                            <i class="fas fa-server"></i>
                        </div>
                        <div>
                            <h4 class="font-bold text-lg mb-2">RARP 响应</h4>
                            <p class="text-gray-700">RARP 服务器接收到请求后，根据设备的 MAC 地址从其数据库中查找对应的 IP 地址，并发送 RARP 响应给设备。</p>
                        </div>
                    </div>
                    
                    <div class="flex items-start">
                        <div class="step-icon" style="background-color: #8b5cf6;">
                            <i class="fas fa-ethernet"></i>
                        </div>
                        <div>
                            <h4 class="font-bold text-lg mb-2">IP 地址分配</h4>
                            <p class="text-gray-700">设备接收到 RARP 响应后，得到其 IP 地址，并可以继续启动和进行网络通信。</p>
                        </div>
                    </div>
                </div>
                
                <h3 class="text-2xl font-semibold mb-4 text-purple-600 border-b border-purple-100 pb-2">主要用途</h3>
                <p class="text-lg leading-relaxed mb-6">
                    将 MAC 地址映射到 IP 地址，以便设备能够在网络中进行通信，特别是在没有持久 IP 配置的情况下。
                </p>
                
                <div class="mermaid mt-10">
                    sequenceDiagram
                        participant D as 设备
                        participant S as RARP服务器
                        D->>网络: RARP请求: 我的MAC是00:1A:2B:3C:4D:5E,IP是什么?
                        S->>D: RARP响应: 你的IP是192.168.1.100
                        D->>网络: 使用IP地址通信
                </div>
            </div>
        </section>

        <!-- Comparison Section -->
        <section class="mb-20">
            <div class="bg-white rounded-xl shadow-md p-8">
                <h2 class="text-3xl font-bold text-gray-800 mb-8 flex items-center">
                    <i class="fas fa-not-equal text-indigo-500 mr-4"></i>
                    ARP与RARP的主要区别
                </h2>
                
                <div class="overflow-x-auto">
                    <table class="min-w-full divide-y divide-gray-200">
                        <thead class="bg-gray-50">
                            <tr>
                                <th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">对比项</th>
                                <th scope="col" class="px-6 py-3 text-left text-xs font-medium text-indigo-500 uppercase tracking-wider">ARP</th>
                                <th scope="col" class="px-6 py-3 text-left text-xs font-medium text-purple-500 uppercase tracking-wider">RARP</th>
                            </tr>
                        </thead>
                        <tbody class="bg-white divide-y divide-gray-200">
                            <tr>
                                <td class="px-6 py-4 whitespace-nowrap font-medium text-gray-900">功能方向</td>
                                <td class="px-6 py-4 whitespace-nowrap">将 IP 地址映射为 MAC 地址</td>
                                <td class="px-6 py-4 whitespace-nowrap">将 MAC 地址映射为 IP 地址</td>
                            </tr>
                            <tr>
                                <td class="px-6 py-4 whitespace-nowrap font-medium text-gray-900">使用场景</td>
                                <td class="px-6 py-4 whitespace-nowrap">局域网中正常的网络操作</td>
                                <td class="px-6 py-4 whitespace-nowrap">设备启动时获取IP地址</td>
                            </tr>
                            <tr>
                                <td class="px-6 py-4 whitespace-nowrap font-medium text-gray-900">现代应用</td>
                                <td class="px-6 py-4 whitespace-nowrap">仍然广泛应用</td>
                                <td class="px-6 py-4 whitespace-nowrap">多被DHCP取代</td>
                            </tr>
                            <tr>
                                <td class="px-6 py-4 whitespace-nowrap font-medium text-gray-900">网络配置</td>
                                <td class="px-6 py-4 whitespace-nowrap">需要知道目标IP地址</td>
                                <td class="px-6 py-4 whitespace-nowrap">需要知道自身MAC地址</td>
                            </tr>
                        </tbody>
                    </table>
                </div>
                
                <div class="mt-12">
                    <div class="mermaid">
                        pie showData
                            title 现代网络使用情况
                            "ARP" : 85
                            "RARP" : 5
                            "DHCP (替代RARP)" : 10
                    </div>
                </div>
            </div>
        </section>

        <!-- Summary -->
        <section class="mb-20">
            <div class="bg-gradient-to-r from-indigo-50 to-purple-50 rounded-xl shadow-md p-8 border border-indigo-100">
                <h2 class="text-2xl font-bold text-indigo-700 mb-6 flex items-center">
                    <i class="fas fa-lightbulb text-yellow-500 mr-3"></i>
                    关键要点总结
                </h2>
                <ul class="space-y-4">
                    <li class="flex items-start">
                        <i class="fas fa-check-circle text-indigo-500 mt-1 mr-3"></i>
                        <span>ARP解决IP到MAC的映射问题，是局域网通信的基础协议</span>
                    </li>
                    <li class="flex items-start">
                        <i class="fas fa-check-circle text-indigo-500 mt-1 mr-3"></i>
                        <span>RARP解决MAC到IP的映射问题，主要用于设备启动时获取IP地址</span>
                    </li>
                    <li class="flex items-start">
                        <i class="fas fa-check-circle text-indigo-500 mt-1 mr-3"></i>
                        <span>现代网络中，RARP已被DHCP协议广泛取代</span>
                    </li>
                    <li class="flex items-start">
                        <i class="fas fa-check-circle text-indigo-500 mt-1 mr-3"></i>
                        <span>理解ARP/RARP有助于诊断网络连接问题和理解网络通信原理</span>
                    </li>
                </ul>
            </div>
        </section>
    </main>

    <!-- Footer -->
    <footer class="bg-gray-900 text-gray-300 py-10">
        <div class="container mx-auto max-w-5xl px-4">
            <div class="flex flex-col md:flex-row justify-between items-center">
                <div class="mb-6 md:mb-0">
                    <h3 class="text-xl font-bold text-white mb-2">技术小馆</h3>
                    <p class="text-gray-400">探索技术奥秘，分享专业见解</p>
                </div>
                <div>
                    <a href="http://www.yuque.com/jtostring" class="footer-link text-indigo-300 hover:text-indigo-200 transition duration-300">
                        <i class="fas fa-globe mr-2"></i>http://www.yuque.com/jtostring
                    </a>
                </div>
            </div>
            <div class="border-t border-gray-800 mt-8 pt-8 text-center text-gray-500 text-sm">
                &copy; 2023 技术小馆. 保留所有权利.
            </div>
        </div>
    </footer>

    <script>
        mermaid.initialize({
            startOnLoad: true,
            theme: 'default',
            flowchart: {
                useMaxWidth: true,
                htmlLabels: true,
                curve: 'basis'
            },
            themeVariables: {
                primaryColor: '#E5E7EB',
                primaryTextColor: '#111827',
                primaryBorderColor: '#D1D5DB',
                lineColor: '#4F46E5',
                secondaryColor: '#8B5CF6',
                tertiaryColor: '#F9FAFB'
            }
        });
    </script>
</body>
</html>
```